package src.data.hbt;

import src.data.hbt.HibernateProvider;

public class Executor {

	public static Object execute(Closure closure) {
		Object result = null;
		try {
			result = closure.execute();
			HibernateProvider.getInstance().commit();

		} catch (Exception e) {
			e.printStackTrace();
			HibernateProvider.getInstance().rollback();
			throw new RuntimeException(e);
		} finally {
			HibernateProvider.getInstance().close();
		}
		return result;
	}

}
